package org.work;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import org.model.Xsb;


public class DBConn {
	Connection conn;
	PreparedStatement pstmt;
	public DBConn() throws SQLException {
		try {
			Class.forName("com.jdbc.mysql.Driver");
			conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/XSCJ", "root", "123456");
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}
	public boolean save(Xsb xs){
		try {
			pstmt=conn.prepareStatement("insert into XSB values(?,?,?,?,?,?)");
			pstmt.setString(1, xs.getXh());
			pstmt.setString(2, xs.getXm());
			pstmt.setString(3, String.valueOf(xs.getXb()));
			pstmt.setString(4, xs.getZy());
			pstmt.setString(5, xs.getCssj().toString());
			pstmt.setString(6, xs.getBz());
			pstmt.executeUpdate();
			return true;
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return false;
		}
		
	}
}
